home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / TURB_VIS / ALEXLEVI / DEMO / DEMO_KBD.C < prev    next >
Text File  |  1994-04-03  |  3KB  |  67 lines

  1.  
  2. /*
  3.  
  4. ****************************************************************************
  5. *                                                                          *
  6. *      This function was made by Alex Levitas' "Keyboard Map Editor".      *
  7. *                                                                          *
  8. ****************************************************************************
  9.  
  10.  This function convert single character from standard keyboard map to new.
  11.  
  12.  May be used after reading single character from keyboard. Use 
  13.  ConvertChar(getch()) call instead of getch() call.
  14.  
  15.  To use this function in your program, insert the directive
  16.  
  17.     #include "DEMO_KBD.C"
  18.  
  19.  If you want to use more than one keyboard map in your program, you
  20.  must change function name in each source file.
  21.  
  22. */
  23.  
  24. char ConvertChar(char PressedChar)
  25.  
  26.  {
  27.  
  28.    static char PreviousChar = 0xFF;
  29.  
  30.    char KeyboardChars[92] = {126, 96, 33, 49, 64, 50, 35, 51, 36, 52,
  31.                               37, 53, 94, 54, 38, 55, 42, 56, 40, 57,
  32.                               41, 48, 95, 45, 43, 61, 81,113, 87,119,
  33.                               69,101, 82,114, 84,116, 89,121, 85,117,
  34.                               73,105, 79,111, 80,112,123, 91,125, 93,
  35.                               65, 97, 83,115, 68,100, 70,102, 71,103,
  36.                               72,104, 74,106, 75,107, 76,108, 58, 59,
  37.                               34, 39, 90,122, 88,120, 67, 99, 86,118,
  38.                               66, 98, 78,110, 77,109, 60, 44, 62, 46,
  39.                               63, 47};
  40.  
  41.    char Convert_Chars[92] = {126, 96, 33, 49, 34, 50, 58, 51, 47, 52,
  42.                               37, 53, 44, 54, 46, 55, 63, 56, 40, 57,
  43.                               41, 48, 95, 45, 43, 61,137,169,150,230,
  44.                              147,227,138,170,133,165,141,173,131,163,
  45.                              152,232,153,233,135,167,149,229,154,234,
  46.                              148,228,155,235,130,162,128,160,143,175,
  47.                              144,224,142,174,139,171,132,164,134,166,
  48.                              157,237,159,239,151,231,145,225,140,172,
  49.                              136,168,146,226,156,236,129,161,158,238,
  50.                              240,241};
  51.  
  52.    int I;
  53.  
  54.    if (!PreviousChar) 
  55.     {
  56.      PreviousChar = PressedChar;
  57.      return(PressedChar);
  58.     };
  59.    PreviousChar = PressedChar;
  60.    for (I = 0; (I < 92) && (PressedChar != KeyboardChars[I]); I++);
  61.    if (I == 92) return (PressedChar);
  62.    if (!Convert_Chars[I]) return (PressedChar);
  63.    return (Convert_Chars[I]);
  64.  
  65.  }
  66.  
  67.